package com.tina.controller;


import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tina.entity.TiOnline;
import com.tina.entity.TiSystemLog;
import com.tina.entity.TiUsers;
import com.tina.mapper.TiSystemLogMapper;
import com.tina.model.ResultFormat;
import com.tina.model.ResultFormatPaging;
import com.tina.util.ResultPagingUtil;
import com.tina.util.ResultUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 在线用户 前端控制器
 * </p>
 *
 * @author Tina
 * @since 2020-06-08
 */
@RestController
@RequestMapping("/tiSystemLog/")
public class TiSystemLogController {

    @Autowired
    private TiSystemLogMapper systemLogMapper;


    private Logger logger = LoggerFactory.getLogger(TiSystemLogController.class);

    /**
     * 查看所有系统日志
     *
     * @return
     */
    @GetMapping("querySystemLog")
    public ResultFormatPaging querySystemLog(TiSystemLog systemLog, @RequestParam("page") Integer page, @RequestParam("limit") Integer limit) {

        AbstractWrapper wrapper = new QueryWrapper<TiSystemLog>();
        if (systemLog != null) {
            if (!StringUtils.isEmpty(systemLog.getLogUserName())) {

            }
        }

        wrapper.orderByDesc("log_start_time");
        Page<TiSystemLog> iPage = new Page<TiSystemLog>(page, limit);
        Page selectPage = systemLogMapper.selectPage(iPage, wrapper);
        List<TiSystemLog> records = selectPage.getRecords();
        return ResultPagingUtil.pagingSuccess(0, selectPage.getTotal(), records);
    }


    public ResultFormat delSystemLog(TiSystemLog systemLog){

        return ResultUtil.success();
    }


}
